# Create your views here.
from django.shortcuts import render_to_response
from models import *
from django.template import RequestContext

def blog(request):
	
	posts = Post.objects.all().order_by("-date")[:5]
	category = Category.objects.all()
	sites = Favorites.objects.all()
	info = AboutMe.objects.all()
	
	return render_to_response("blog.html", locals())
	
def aboutme(request):
	info = AboutMe.objects.all()
	return render_to_response("aboutme.html", locals())
	

def category(request):
	if request.method == "POST":
		name = request.POST.get('name')
		post = Post.objects.get(category = name)
		return render_to_response("category.html", locals())
	else:
		return render_to_response("category.html", RequestContext(request))